CalcRiskLookupTable <- function(RLA_Rate,BNcK_Rate,RecertSchedule) {
  
  # This is the "Reverse Function" designed to give a PM 
  # the power to ask, "What do I need to chieve this result?"
  #
  # RiskLimits - 2x2 - [xmin ymin;
  #                     xmax ymax]
  #===========================================================================
  
  OpYears = length(RecertSchedule)
  N = length(RLA_Rate)
  
#   SDTF = BNcK_Rate >RLA_Rate # Supply-Demand True-False
#   if (any(SDTF)) {
#     xx = which(SDTF)
#     BNcK_Rate[xx] = RLA_Rate[xx]
#   }
  
  YearlyDemand = ceiling(outer(BNcK_Rate,RecertSchedule))  #simple calculation of number replaced rounded to next integer.  Can change this to distributed method
  #N by t vector has all predicted replacements for a given part along a single row
  
  # This part needs to change to reflect the fact that Purchases may go through a lot of different
  # variations as a result of user input, but for now it is what it is.
  InitialPurchase = 2
  
  aseq = seq(0,1,by=.1)
  sseq = seq(1,2,by=0.1)
  rseq = seq(50,80,by=5)
  
#   aseq = seq(0,1,by=.5)
#   sseq = seq(1,4,by=1)
#   rseq = seq(40,100,by=10)
  
  Risk = c(0,0)
  RiskConf = array(0,dim=c(length(sseq),length(aseq),length(rseq)))
  RiskCost = RiskConf
  CostLimits = array(0,dim=c(length(sseq),2))
  ConfLimits = CostLimits
  FinalPurchases = NULL
  
  s = 0
  for (Scale in sseq) { 
    s = s +1
    a = 0
    for (alpha in aseq) {
      a = a +1
      r = 0
      for (RR in rseq) { # RR = RecertRate
        r = r +1
        Purchases = CalcPurchase(alpha,RLA_Rate,BNcK_Rate,RecertSchedule,Scale)
        thisRisk = CalcRiskCube(InitialPurchase,Purchases,YearlyDemand,RecertSchedule,RR)
#         print("Stopped at Line 53")
#         browser()
        RiskCost[s,a,r] = thisRisk[1] 
        RiskConf[s,a,r] = thisRisk[2] 
      }
    }
    CostLimits[s,] = c(min(RiskCost[s,,]),max(RiskCost[s,,]))
    ConfLimits[s,] = c(min(RiskConf[s,,]),max(RiskConf[s,,]))
    print("Finished a Scale...")
  }
  
  RiskTable = list("Alpha"=aseq,"Scale"=sseq,"RecertRate"=rseq,
                   "RiskConf"=RiskConf,"RiskCost"=RiskCost,
                   "CostLimits"=CostLimits,"ConfLimits"=ConfLimits)
  
  plot(RiskTable$RiskCost,RiskTable$RiskConf)
  return(RiskTable)
}